#encoding "utf-8"
=begin

Usage:  this script create more owner for specific store id
Syntax: ruby create-more-owner.rb id, storeName, ownerPhone, ownerName [uid]
        id must > 1
Example ruby create-store.rb 2 测试小店 13600060044 董学锋

=end

require 'securerandom'
load 'rds_api.rb'

def create_store_owner store_id, phone, owner

  puts "create store owner for store ##{store_id}"
  sql = "INSERT INTO `crmeb`.`eb_system_admin` ( `account`, `pwd`, `real_name`, `roles`, `last_ip`, `last_time`, `add_time`, `login_count`, `level`, `status`, `is_del`, `mer_id` ) VALUES ( '_PHONE', '_PASSWD', '_OWNER', '2', NULL, NULL, 1591234902, 0, 1, 1, 0, _MER_ID );"
  default_passwd = '8dd8503c49b5e8c6aaea1ed7f0c49765' #18898382701 FxxxxS rule
  sql = sql.gsub('_PHONE',phone).gsub('_PASSWD',default_passwd).gsub('_OWNER',owner).gsub('_MER_ID',"#{store_id}");
  queryRds sql

end

id = ARGV[0].to_i
store = ARGV[1]
phone = ARGV[2]
owner = ARGV[3]
uid = ARGV[4] 

if id < 1 || ARGV.size < 4
  puts "Usage:  ruby create-more-owner.rb id storeName ownerPhone ownerName [uid]"
  puts "        id must >= 1"
  exit
end

create_store_owner id, phone, owner
